<%@ page language="java" import="com.tbrain.secretFriend.util.*,com.tbrain.secretFriend.service.*,com.tbrain.secretFriend.model.*,java.sql.*" pageEncoding="ISO-8859-1"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
	String userNameParam 	= request.getParameter("userName");
	String passwordParam	= request.getParameter("password");
	Connection conn = ConnectionHelper.getConnection();
	UserService userService = new UserService(conn);
	try{
		userService.calculateAllSecretFriend();

		User user = userService.selectByUserName(userNameParam); 

		if(userService.isValidUser(user,passwordParam)){
			session.setAttribute("user",user);
			request.getRequestDispatcher("./wishList.jsp").forward(request,response);
		}
	}catch(Exception e){
		session.setAttribute("errorMessage",e);
		request.getRequestDispatcher("./index.jsp").forward(request,response);
	}finally{
		if(conn!=null){
			conn.close();
		}
	}
%>
</body>
</html>